/**
 @file ctc_ipfix.h

 @author  Copyright (C) 2013 Centec Networks Inc.  All rights reserved.

 @date 2013-10-13

 @version v3.0

 This file contains all port related data structure, enum, macro and proto.

*/

#ifndef _CTC_IPFIX_H
#define _CTC_IPFIX_H
#ifdef __cplusplus
extern "C" {
#endif

/****************************************************************
 *
 * Header Files
 *
 ***************************************************************/

#include "ctc_const.h"
#include "ctc_acl.h"
#include "ctc_xdata.h"
/****************************************************************
*
* Defines and Macros
*
****************************************************************/
#define CTC_IPFIX_PROFILE_NUM 256
/**
 @defgroup ipfix IPFIX
 @{
*/

#define CTC_IPFIX_LABEL_NUM          3

/**
 @brief  IPFIX flag define
*/
enum ctc_ipfix_data_flags_e
{
    CTC_IPFIX_DATA_L2_MCAST_DETECTED      = (1 << 0),             /**< [GG.D2.TM.TMM.AT]  Session destid is L2Mcast*/
    CTC_IPFIX_DATA_L3_MCAST_DETECTED      = (1 << 1),             /**< [GG.D2.TM.TMM.AT]  Session destid is L3Mcast*/
    CTC_IPFIX_DATA_BCAST_DETECTED         = (1 << 2),             /**< [GG.D2.TM.TMM.AT]  Session destid is BMcast*/
    CTC_IPFIX_DATA_APS_DETECTED           = (1 << 3),             /**< [GG.D2.TM.TMM.AT]  Session destid is APS Group*/
    CTC_IPFIX_DATA_ECMP_DETECTED          = (1 << 4),             /**< [GG] Session destid is ECMP Group*/
    CTC_IPFIX_DATA_LINKAGG_DETECTED       = (1 << 5),             /**< [GG.D2.TM.TMM.AT]  Session destid is Linkagg Group*/
    CTC_IPFIX_DATA_UNKNOW_PKT_DETECTED    = (1 << 6),             /**< [GG.D2.TM.TMM.AT]  Unkown Packet detect*/
    CTC_IPFIX_DATA_FRAGMENT_PKT_DETECTED  = (1 << 7),             /**< [GG.D2.TM.TMM.AT]  Fragment Packet detect*/
    CTC_IPFIX_DATA_DROP_DETECTED          = (1 << 8),             /**< [GG.D2.TM.TMM.AT]  Drop Packrt detect*/
    CTC_IPFIX_DATA_TTL_CHANGE             = (1 << 9),             /**< [GG] TTL change in this session*/
    CTC_IPFIX_DATA_CVLAN_TAGGED           = (1 << 10),            /**< [GG.D2.TM.TMM.AT]  Ipfix key cvlan valid*/
    CTC_IPFIX_DATA_SVLAN_TAGGED           = (1 << 11),            /**< [GG.D2.TM.TMM.AT]  Ipfix key svlan valid*/
    CTC_IPFIX_DATA_SRC_CID_VALID          = (1 << 12),            /**< [D2.TM.TMM.AT]     Ipfix key src cid valid*/
    CTC_IPFIX_DATA_DST_CID_VALID          = (1 << 13),            /**< [D2.TM.TMM.AT]     Ipfix key dst cid valid*/
    CTC_IPFIX_DATA_MFP_VALID              = (1 << 14),            /**< [TM]       Session enable micro flow policer */
    CTC_IPFIX_DATA_RESOLVE_HASH_CONFLICT  = (1 << 15)             /**< [AT] Enable resolve hash conflict by hash salt */
};
typedef enum ctc_ipfix_data_flags_e ctc_ipfix_data_flags_t;

/**
 @brief  IPFIX Export Reason define
*/
enum ctc_ipfix_export_reason_e
{
    CTC_IPFIX_NO_EXPORT,
    CTC_IPFIX_REASON_EXPIRED,                                  /**< [GG.D2.TM.TMM.AT]  Export reason is time expired */
    CTC_IPFIX_REASON_TCP_CLOSE,                                /**< [GG.D2.TM.TMM.AT]  Export reason is Tcp session close */
    CTC_IPFIX_REASON_PACKET_CNT_OVERFLOW,                      /**< [GG.D2.TM.TMM.AT]  Export reason is packet count overflow */
    CTC_IPFIX_REASON_BYTE_CNT_OVERFLOW,                        /**< [GG.D2.TM.TMM.AT]  Export reason is packet byte overflow */
    CTC_IPFIX_REASON_LAST_TS_OVERFLOW,                         /**< [GG.D2.TM.TMM.AT]  Export reason is ts overflow */
    CTC_IPFIX_REASON_HASH_CONFLICT,                            /**< [GG.AT] Export reason is hash conflict */
    CTC_IPFIX_REASON_NEW_FLOW_INSERT,                          /**< [GG.D2.TM.TMM.AT]  Export reason is new flow insert */
    CTC_IPFIX_REASON_DEST_CHANGE,                              /**< [GG.D2.TM.TMM.AT]  Export reason is dest info change */

    CTC_IPFIX_REASON_JITTER_OVERFLOW,                          /**< [TMM.AT]  Export reason is jitter overflow */
    CTC_IPFIX_REASON_LATENCY_OVERFLOW,                         /**< [TMM.AT]  Export reason is latency overflow */
    CTC_IPFIX_REASON_TTL_CHANGE,                               /**< [TMM.AT]  Export reason is TTL Change*/
    CTC_IPFIX_REASON_DROP_CNT_OVERFLOW,                        /**< [TMM.AT]  Export reason is drop packet count overflow*/
    CTC_IPFIX_REASON_DROP_REASON_CHANGE,                       /**< [TMM.AT]  Export reason is drop reason change*/
    CTC_IPFIX_REASON_TC_MARK,                                  /**< [TMM]  Export reason is traffic color mark */
    CTC_IPFIX_REASON_DUMP,                                     /**< [TMM.AT]  Export reason is dump */
    CTC_IPFIX_REASON_BUFFER_DROP,                              /**< [AT] Export reason is buffer resource drop */
    CTC_IPFIX_REASON_BURST_EVENT,                              /**< [AT] Export reason when packet generate buffer burst event */
    CTC_IPFIX_REASON_LATENCY_EVENT,                            /**< [AT] Export reason when packet generate big latency event */    
    CTC_IPFIX_REASON_BURST_CNT_OVERFLOW,                     /**< [AT] Export reason when packet buffer burst event count overflow*/
    CTC_IPFIX_REASON_LATENCY_CNT_OVERFLOW,                   /**< [AT] Export reason when packet big latency event count overflow*/   
    CTC_IPFIX_REASON_MAX
};
typedef enum ctc_ipfix_export_reason_e ctc_ipfix_export_reason_t;

/**
 @brief  IPFIX aim to packet type
*/
enum ctc_ipfix_flow_type_e
{
    CTC_IPFIX_FLOW_TYPE_ALL_PACKET                = 0x0000,     /**< [GG.D2.TM.TMM.AT]  Do ipfix for all packets including Discard and Non-discard */

    CTC_IPFIX_FLOW_TYPE_NON_DISCARD_PACKET        = 0x0001,     /**< [GG.D2.TM.TMM.AT]  Only do ipfix for Non-discard packets */
    CTC_IPFIX_FLOW_TYPE_DISCARD_PACKET            = 0x0002,     /**< [GG.D2.TM.TMM.AT]  Only do ipfix for Discard packets */

    CTC_IPFIX_FLOW_TYPE_NON_BURST                 = 0x0004,     /**< [AT] Only do ipfix for Non-burst packets */
    CTC_IPFIX_FLOW_TYPE_BURST                     = 0x0008,     /**< [AT] Only do ipfix for burst packets */

    CTC_IPFIX_FLOW_TYPE_NON_LATENCY             = 0x0010,     /**< [AT] Only do ipfix for packets between the effective interval*/
    CTC_IPFIX_FLOW_TYPE_LATENCY                   = 0x0020,     /**< [AT] Only do ipfix for latency packets */


    CTC_IPFIX_FLOW_TYPE_MAX
};
typedef enum ctc_ipfix_flow_type_e ctc_ipfix_flow_type_t;

/**
 @brief  IPFIX mpls label info
*/
struct ctc_ipfix_label_info_s
{
    uint8  ttl;        /**< [GG.D2.TM.TMM.AT]  TTL value*/
    uint8  exp;        /**< [GG.D2.TM.TMM.AT]  EXP value*/
    uint8  sbit;       /**< [GG.D2.TM.TMM.AT]  Sbit value*/
    uint32 label;      /**< [GG.D2.TM.TMM.AT]  MPLS label value*/
};
typedef struct ctc_ipfix_label_info_s ctc_ipfix_label_info_t;

/**
 @brief  IPFIX l3 info struct
*/
struct ctc_ipfix_l3_info_s
{
    struct
    {
        uint8 ttl;                             /**< [GG.D2.TM.TMM.AT]  TTL value*/
        uint8 dscp;                            /**< [GG.D2.TM.TMM.AT]  DSCP value*/
        uint8 ecn;                             /**< [GG.D2.TM.TMM.AT]  Ip Ecn value*/
        uint8 ipda_masklen;                    /**< [GG.D2.TM.TMM.AT]  Only used for Cpu construct key, length should be 1~32*/
        uint8 ipsa_masklen;                    /**< [GG.D2.TM.TMM.AT]  Only used for Cpu construct key, length should be 1~32*/
        uint16  ip_pkt_len;                    /**< [D2.TM.TMM.AT]  Ip packet length,only for ipv4 key*/
        uint16  ip_identification;             /**< [D2.TM.TMM.AT]  Ip packet identification.*/
        ip_addr_t ipda;                        /**< [GG.D2.TM.TMM.AT]  IPV4 ip da*/
        ip_addr_t ipsa;                        /**< [GG.D2.TM.TMM.AT]  IPV4 ip sa*/
    }ipv4;
    struct
    {
        uint32 flow_label;                     /**< [GG.D2.TM.TMM.AT]  Flow Label*/
        uint8 dscp;                            /**< [GG.D2.TM.TMM.AT]  DSCP value*/
        uint8 ttl;                             /**< [D2.TM.TMM.AT]  TTL value*/
        uint8 ecn;                             /**< [D2.TM.TMM.AT]  Ip Ecn value*/
        uint8 ipda_masklen;                    /**< [GG.D2.TM.TMM.AT]  Only used for Cpu construct key, length should be 4*n*/
        uint8 ipsa_masklen;                    /**< [GG.D2.TM.TMM.AT]  Only used for Cpu construct key, length should be 4*n*/
        ipv6_addr_t ipda;                      /**< [GG.D2.TM.TMM.AT]  IPV6 ip da*/
        ipv6_addr_t ipsa;                      /**< [GG.D2.TM.TMM.AT]  IPV6 ip sa*/
    }ipv6;

    struct
    {
        uint8 label_num;                                         /**< [GG.D2.TM.TMM.AT]  MPLS lable number*/
        ctc_ipfix_label_info_t label[CTC_IPFIX_LABEL_NUM];       /**< [GG.D2.TM.TMM.AT]  MPLS lable*/
    }
    mpls;
    struct
    {
        ip_addr_t sender_ip;                   /**< [AT] Arp sende IP */
        ip_addr_t target_ip;                   /**< [AT] Arp target IP */
        mac_addr_t sender_mac;                 /**< [AT] Arp sender address. */
        mac_addr_t target_mac;                 /**< [AT] Arp target address. */
        uint16 op_code;                        /**< [AT] Arp op code */
    }arp;

    uint32 vrfid;                              /**< [GG.D2.TM.TMM.AT]  Vrfid value*/
    uint8  ip_frag;                            /**< [D2.TM.TMM.AT]  Ip fragment, refer to ctc_ip_frag_t*/
};
typedef struct ctc_ipfix_l3_info_s ctc_ipfix_l3_info_t;

/**
 @brief  IPFIX l4 info struct
*/
struct ctc_ipfix_l4_info_s
{
    union
    {
        uint16 l4_type;                   /**< [GG] refer to ctc_ipfix_l4_type_t, used for l2l3 and ipv6 key*/
        uint16 ip_protocol;               /**< [GG.D2.TM.TMM.AT]  used for ipv4 ipv6 l2l3 and ipv4 ipv6 single key*/
    }type;

    struct
    {
        uint16 source_port;               /**< [GG.D2.TM.TMM.AT]  Source port value*/
        uint16 dest_port;                 /**< [GG.D2.TM.TMM.AT]  Destination port value*/
    }l4_port;

    struct
    {
        uint8 icmpcode;                   /**< [GG.D2.TM.TMM.AT]  Icmpcode value*/
        uint8 icmp_type;                  /**< [GG.D2.TM.TMM.AT]  Icmp type*/
    }icmp;

    struct
    {
        uint8 igmp_type;                  /**< [D2.TM.TMM.AT]  Igmp type value*/
    }igmp;
    uint32 l4_sub_type;                   /**< [GG] refer to ctc_ipfix_l4_sub_type_t, used for l2l3 ipv4 ipv6 key. When used for ipv6, only support vxlan_vin*/
    uint32 gre_key;                       /**< [GG.D2.TM.TMM.AT]  GRE key or NVGRE vsid*/
    uint32 vni;                           /**< [GG.D2.TM.TMM.AT]  Vni key*/
    uint8  aware_tunnel_info_en;          /**< [GG.D2.TM.TMM.AT]  if enable, indicate lookup key use innner info as key, and outer tunnel info can also be used as lookup key*/


    struct
    {
        uint8      radio_id;              /**< [D2.TM] Radio id value*/
        uint8      is_ctl_pkt;            /**< [D2.TM] Is wlan control packet*/
        mac_addr_t radio_mac;             /**< [D2.TM] Radio mac*/
    }wlan;

    uint8 tcp_flags;                      /**< [D2.TM.TMM.AT] tcp flags, consist of CWR|ECE|URG|ACK|PSH|RST|SYN|FIN*/


};
typedef struct ctc_ipfix_l4_info_s ctc_ipfix_l4_info_t;

/**
 @brief  IPFIX Port Type
*/
enum ctc_ipfix_port_type_s
{
    CTC_IPFIX_PORT_TYPE_NONE,           /**< [GG.D2.TM.TMM.AT]  Donot using Gport/LogicPort/metedara as key */
    CTC_IPFIX_PORT_TYPE_GPORT,          /**< [GG.D2.TM.TMM.AT]  Using GlobalPort as key */
    CTC_IPFIX_PORT_TYPE_LOGIC_PORT,     /**< [GG.D2.TM.TMM.AT]  Using LogicPort as key */
    CTC_IPFIX_PORT_TYPE_METADATA,       /**< [GG.D2.TM.TMM.AT]  Using Metadata as key */
};
typedef enum ctc_ipfix_port_type_s ctc_ipfix_port_type_t;

/** @brief  IPFIX Key Type */
enum ctc_ipfix_key_type_e
{
    CTC_IPFIX_KEY_HASH_MAC,           /**< [GG.D2.TM.TMM.AT]  MAC Hash key type */
    CTC_IPFIX_KEY_HASH_L2_L3,         /**< [GG.D2.TM.TMM.AT]  L2 L3 Hash key type */
    CTC_IPFIX_KEY_HASH_IPV4,          /**< [GG.D2.TM.TMM.AT]  IPv4 Hash key type */
    CTC_IPFIX_KEY_HASH_IPV6,          /**< [GG.D2.TM.TMM.AT]  IPv6 Hash key type */
    CTC_IPFIX_KEY_HASH_MPLS,          /**< [GG.D2.TM.TMM.AT]  MPLS Hash key type */
    CTC_IPFIX_KEY_HASH_UDF,           /**< [TMM.AT] UDF Hash key type */
    CTC_IPFIX_KEY_HASH_UDF_SINGLE,    /**< [AT] UDF Single Hash key type */
    CTC_IPFIX_KEY_HASH_IPV4_SINGLE,   /**< [AT] IPv4 Single Hash key type */
    CTC_IPFIX_KEY_HASH_IPV6_SINGLE,   /**< [AT] IPv6 Single Hash key type */
    CTC_IPFIX_KEY_HASH_MPLS_SINGLE,   /**< [AT] MPLS Single Hash key type */
    CTC_IPFIX_KEY_HASH_FLEX_BASE,     /**< [AT] Flex key base key type*/
    CTC_IPFIX_KEY_HASH_FLEX_END = 254,/**< [AT] Flex key end key type*/
    CTC_IPFIX_KEY_NUM
};
typedef enum ctc_ipfix_key_type_e ctc_ipfix_key_type_t;

/**
 @brief  Define flex nexthop use packet type
*/
enum ctc_ipfix_l4_type_e
{
    CTC_IPFIX_L4_TYPE_NONE,             /**< [GG] no l4 type*/
    CTC_IPFIX_L4_TYPE_TCP,              /**< [GG] 1: l4 type is TCP*/
    CTC_IPFIX_L4_TYPE_UDP,              /**< [GG] 2: l4 type is UDP*/
    CTC_IPFIX_L4_TYPE_GRE,              /**< [GG] 3: l4 type is GRE*/
    CTC_IPFIX_L4_TYPE_IPINIP,           /**< [GG] 4: l4 type is IPINIP*/
    CTC_IPFIX_L4_TYPE_V6INIP,           /**< [GG] 5: l4 type is V6INIP*/
    CTC_IPFIX_L4_TYPE_ICMP,             /**< [GG] 6: l4 type is ICMP*/
    CTC_IPFIX_L4_TYPE_IGMP,             /**< [GG] 7: l4 type is IGMP*/
    CTC_IPFIX_L4_TYPE_SCTP,             /**< [GG] 8: l4 type is SCTP*/
    CTC_IPFIX_L4_TYPE_MAX
};
typedef enum ctc_ipfix_l4_type_e ctc_ipfix_l4_type_t;

/**
 @brief  Define flex nexthop use packet type
*/
enum ctc_ipfix_l4_sub_type_e
{
    CTC_IPFIX_L4_SUB_TYPE_NONE,           /**< [GG] no l4 sub type, for l4 type is UDP*/
    CTC_IPFIX_L4_SUB_TYPE_BFD,            /**< [GG] 1: l4 sub type is BFD, for l4 type is UDP*/
    CTC_IPFIX_L4_SUB_TYPE_UDPPTP,         /**< [GG] 2: l4 sub type is UDPPTP,for l4 type is UDP*/
    CTC_IPFIX_L4_SUB_TYPE_WLAN,           /**< [GG] 3: l4 sub type is WLAN, for l4 type is UDP*/
    CTC_IPFIX_L4_SUB_TYPE_NTP,            /**< [GG] 4: l4 sub type is NTP, for l4 type is UDP*/
    CTC_IPFIX_L4_SUB_TYPE_VXLAN,          /**< [GG] 5: l4 sub type is VXLAN, for l4 type is UDP*/
    CTC_IPFIX_L4_SUB_TYPE_MAX
};
typedef enum ctc_ipfix_l4_sub_type_e ctc_ipfix_l4_sub_type_t;

/**
 @brief  Define flex key field 
*/
struct ctc_ipfix_field_key_s
{
    ctc_field_key_t* field_list;        /**< [AT] Flex key field list*/
    uint32 field_num;                   /**< [AT] Flex key field number*/
};
typedef struct ctc_ipfix_field_key_s ctc_ipfix_field_key_t;

/**
 @brief  IPFIX Data struct, including key and ad info
 for Export all info is usefull; for lookup and cpu add/del only key info is usefull
*/
struct ctc_ipfix_data_s
{
    uint32 flags;                    /**< [GG.D2.TM.TMM.AT]  reger to ctc_ipfix_data_flags_t */
    uint32 port_type;                /**< [GG.D2.TM.TMM.AT]  refer to ctc_ipfix_port_type_t*/
    uint32 key_type;                 /**< [GG.D2.TM.TMM.AT]  refer to ctc_ipfix_key_type_t*/
    uint32 key_index;                /**< [TM.TMM] hardware key index*/

    uint32 gport;                    /**< [GG.D2.TM.TMM.AT]  Used to identify local phy port, also identify GlobalPort if port_type is CTC_IPFIX_PORT_TYPE_GPORT */
    uint16 logic_port;               /**< [GG.D2.TM.TMM.AT]  Used to identify logic port or meter data, depends on port_type. */
    uint16 svlan;                    /**< [GG.D2.TM.TMM.AT]  VLAN identifier. */
    uint16 svlan_prio;               /**< [GG.D2.TM.TMM.AT]  VLAN priority. */
    uint16 svlan_cfi;                /**< [GG.D2.TM.TMM.AT]  VLAN CFI*/
    uint16 cvlan;                    /**< [GG.D2.TM.TMM.AT]  VLAN identifier. */
    uint16 cvlan_prio;               /**< [GG.D2.TM.TMM.AT]  VLAN priority. */
    uint16 cvlan_cfi;                /**< [GG.D2.TM.TMM.AT]  VLAN CFI*/
    uint16 ether_type;               /**< [GG.D2.TM.TMM.AT]  Type in ethernet II frame or 802.1Q tag. */
    uint16  src_cid;                 /**< [D2.TM.TMM.AT]  Source category id*/
    uint16  dst_cid;                 /**< [D2.TM.TMM.AT]  Dest category id*/
    uint8  profile_id;               /**< [D2.TM.TMM.AT]  config profile ID. */
    uint8  field_sel_id;             /**< [D2.GG.TM.TMM.AT]  Hash select ID. */
    mac_addr_t src_mac;              /**< [GG.D2.TM.TMM.AT]  Source MAC address. */
    mac_addr_t dst_mac;              /**< [GG.D2.TM.TMM.AT]  Destination MAC address. */

    ctc_ipfix_l3_info_t l3_info;     /**< [GG.D2.TM.TMM.AT]  Layer3 data. */
    ctc_ipfix_l4_info_t l4_info;     /**< [GG.D2.TM.TMM.AT]  Layer4 data. */

    uint32 udf_id;                   /**< [AT] UDF ID*/
    uint8  udf[CTC_ACL_UDF_BYTE_NUM];/**< [AT] The offset of each UDF field*/

    uint16 fid;                      /**< [TMM.AT]  fid(forwarding identifiy) which use for fdb/vpls/vxlan/..*/
    uint16 hash_salt;                /**< [AT] Used to solve hash conflict */

    ctc_direction_t dir;             /**< [GG.D2.TM.TMM.AT]  Ingress or egress. */

    /*Ingress export infomation*/
    uint32  export_reason;           /**< [GG.D2.TM.TMM.AT]  Export reason used to construct ad information */
    uint32  start_timestamp;         /**< [GG.D2.TM.TMM.AT]  Start timestamp in this session. */
    uint32  last_timestamp;          /**< [GG.D2.TM.TMM.AT]  Last timestamp in this session. */
    uint64  byte_count;              /**< [GG.D2.TM.TMM.AT]  Total byts count in this session. */
    uint32  pkt_count;               /**< [GG.D2.TM.TMM.AT]  Total packets count in this session. */
    uint8   ttl;                     /**< [GG] TTL value of the first packet. */
    uint8   min_ttl;                 /**< [GG.D2.TM.TMM.AT]  Min ttl value in  all packets. */
    uint8   max_ttl;                 /**< [GG.D2.TM.TMM.AT]  Max ttl value in all packets. */
    uint8   last_ttl;                /**< [TMM.AT] Last ttl value. */
    uint8   tcp_flags;               /**< [D2.TM.TMM.AT]  Tcp flags status, consist of CWR|ECE|URG|ACK|PSH|RST|SYN|FIN */
    uint32  dest_gport;              /**< [GG.D2.TM.TMM.AT]  Destination global port ID for unicast, include LinkAgg, valid if CTC_PKT_FLAG_MCAST is not set */
    uint16  dest_group_id;           /**< [GG.D2.TM.TMM.AT]  Destination group ID for multicast, valid if CTC_PKT_FLAG_MCAST is set */
    uint32  drop_reason_bmp[2];      /**< [TMM.AT]  Drop reason bitmap, refer to ctc_drop_reason_t */
    uint16  drop_pkt_cnt[2];         /**< [TMM.AT]  First Drop reason packet count */
    uint8   drop_reason[2];          /**< [TM.TMM.AT]  First Drop reason, only support one drop reason for TM*/

    /*MMU export infomation, together with ingress*/
    uint32 dest_port;             /**< [AT] Destination port*/
    uint8  queue_id;                 /**< [AT] Queue id */
    uint32 queue_count;              /**< [AT] Queue buffer count (depth)*/
    uint32 min_queue_count;          /**< [AT] Min queue count export threshold */
    uint32 max_queue_count;          /**< [AT] Max queue count export threshold */
    uint8 burst_state;               /**< [AT] If set, the mmu is in burst state*/
    uint16 buf_drop_reason[2];       /**< [AT] Buffer drop reason bitmap for resource check fail, refer to ctc_qos_buffer_type_t, 0: irm,1: erm*/
    uint16 buf_drop_cnt;             /**< [AT] Buffer drop count of resource check fail*/

    /*Egress export infomation*/
    uint32  max_latency;              /**< [TM.TMM.AT]  max latency stats, uint:ns*/
    uint32  min_latency;              /**< [TM.TMM.AT]  min latency stats, uint:ns*/
    uint32  avg_latency;              /**< [TMM.AT]  average latency stats, uint:ns*/
    uint32  last_latency;             /**< [TMM.AT]  last packet latency , uint:ns*/
    uint32  max_jitter;               /**< [TM.TMM.AT]  max jitter stats, uint:ns*/
    uint32  min_jitter;               /**< [TM] min jitter stats, uint:ns*/
    uint32  avg_jitter;               /**< [TM.TMM.AT]  average jitter stats, uint:ns*/
    uint64  e_byte_count;             /**< [TMM]  Total byts count in this session. */
    uint32  e_pkt_count;              /**< [TMM]  Total packets count */
    uint32  e_drop_reason_bmp[2];     /**< [TMM]  Drop reason bitmap, refer to ctc_drop_reason_t */
    uint16  e_drop_pkt_cnt[2];        /**< [TMM]  First Drop reason packet count */
    uint8   e_drop_reason[2];         /**< [TMM]  First Drop reason */
    uint32  burst_cnt;                /**< [AT] Burst packet count,it's used for the burst reason by alu*/
    uint32  latency_cnt;              /**< [AT] Latency packet count,it's used for the latency reason by alu */
    
    ctc_ipfix_field_key_t flex_key;   /**< [AT] flex key field */
    ctc_xdata_t xdata;                /**< [AT] xdata, only valid for CTC_FIELD_KEY_XDATA */

    struct ctc_ipfix_data_s* p_next;  /**< [TMM.AT]  When p_next is not NULL, indicates have next, only for exporting */

    uint16 pp_bmp;                    /**< [AT] PP bitmap */
} ;
typedef struct ctc_ipfix_data_s ctc_ipfix_data_t;

/**
 @brief define ipfix lkup type
*/
enum ctc_ipfix_lkup_type_e
{
    CTC_IPFIX_HASH_LKUP_TYPE_DISABLE,     /**< [GG.D2.TM.TMM.AT] Disable */
    CTC_IPFIX_HASH_LKUP_TYPE_L2,          /**< [GG.D2.TM.TMM.AT] only use l2 field*/
    CTC_IPFIX_HASH_LKUP_TYPE_L3,          /**< [GG.D2.TM.TMM.AT] only use l3 field*/
    CTC_IPFIX_HASH_LKUP_TYPE_L2L3,        /**< [GG.D2.TM.TMM.AT] L2+ L3, Notice if using l2l3 type, must using etherType as one of hashsel elements*/
    CTC_IPFIX_HASH_LKUP_TYPE_L3_SINGLE,   /**< [AT] Use L3 single key */
    CTC_IPFIX_HASH_LKUP_TYPE_UDF_SINGLE,  /**< [AT] Use UDF single key */
    CTC_IPFIX_HASH_LKUP_TYPE_UDF,         /**< [AT] Use UDF key  */
    CTC_IPFIX_HASH_LKUP_TYPE_MAX
};
typedef enum ctc_ipfix_lkup_type_e ctc_ipfix_lkup_type_t;
/**
 @brief define ipfix hash mac field sel
*/
struct ctc_ipfix_hash_mac_field_sel_s
{
    uint8 mac_da;                /**< [GG.D2.TM.TMM.AT]  MAC DA select enable*/
    uint8 mac_sa;                /**< [GG.D2.TM.TMM.AT]  MAC SA select enable*/
    uint8 eth_type;              /**< [GG.D2.TM.TMM.AT]  Eth-Type select enable*/
    uint8 gport;                 /**< [GG.D2.TM.TMM.AT]  Using gport hash, not gport value*/
    uint8 logic_port;            /**< [GG.D2.TM.TMM.AT]  Logic port select enable*/
    uint8 metadata;              /**< [GG.D2.TM.TMM.AT]  Metadata select enable*/
    uint8 cos;                   /**< [GG.D2.TM.TMM.AT]  COS select enable*/
    uint8 cfi;                   /**< [GG.D2.TM.TMM.AT]  CFI SA select enable*/
    uint8 vlan_id;               /**< [GG.D2.TM.TMM.AT]  VLAN select enable*/
    uint8 src_cid;               /**< [D2.TM.TMM.AT]  src category id select enable*/
    uint8 dst_cid;               /**< [D2.TM.TMM.AT]  dst category id select enable*/

    uint8 ctag_cos;              /**< [TMM.AT]  CVLAN COS select enable*/
    uint8 ctag_cfi;              /**< [TMM.AT]  CVLAN CFI select enable*/
    uint8 ctag_vlan;             /**< [TMM.AT]  CVLAN select enable*/
    uint8 fid;                   /**< [TMM.AT]  Fid which use for l2/vxlan/gre/mpls tunnel l2 forwarding id*/

    uint8 profile_id;            /**< [D2.TM.TMM.AT]  Config profile id select enable*/
};
typedef struct ctc_ipfix_hash_mac_field_sel_s ctc_ipfix_hash_mac_field_sel_t;
/**
 @brief define ipfix hash ipv4 field sel
*/
struct ctc_ipfix_hash_ipv4_field_sel_s
{
    /* Single key */
    uint8  ip_da;             /**< [GG.D2.TM.TMM.AT]  IP DA select enable*/
    uint8  ip_da_mask;        /**< [GG.D2.TM.TMM.AT]  IP DA mask length*/
    uint8  ip_sa;             /**< [GG.D2.TM.TMM.AT]  IP SA select enable*/
    uint8  ip_sa_mask;        /**< [GG.D2.TM.TMM.AT]  IP SA mask length*/
    uint8  ip_protocol;       /**< [GG.D2.TM.TMM.AT]  IP protocol select enable*/

    uint8  l4_src_port;       /**< [GG.D2.TM.TMM.AT]  l4 source port select enable*/
    uint8  l4_dst_port;       /**< [GG.D2.TM.TMM.AT]  l4 destination port select enable*/

    uint8  icmp_type;         /**< [GG.D2.TM.TMM.AT]  ICMP type select enable*/
    uint8  icmp_code;         /**< [GG.D2.TM.TMM.AT]  ICMP code select enable*/
    uint8  igmp_type;         /**< [D2.TM.TMM.AT]  IGMP type select enable*/

    uint8  sym_session_en;    /**< [TMM.AT]  Ip sysmetric session enable which ipda/ipsa and tcp src/dst five tuple as one session*/
    uint8  profile_id;        /**< [D2.TM.TMM.AT]  config profile id select enable*/

    /* full key */
    uint8  gport;             /**< [GG.D2.TM.TMM.AT]  Gport select enable*/
    uint8  logic_port;        /**< [GG.D2.TM.TMM.AT]  Logic port select enable*/
    uint8  metadata;          /**< [GG.D2.TM.TMM.AT]  Metadata select enable*/
    uint8  dscp;              /**< [GG.D2.TM.TMM.AT]  DSCP select enable*/
    uint8  ttl;               /**< [D2.TM.TMM.AT]  TTL select enable*/
    uint8  ecn;               /**< [D2.TM.TMM.AT]  ECN select enable*/
    uint8  l4_sub_type;       /**< [GG] Before cfg l4_sub_type, first enable ip_protocol*/
    uint8  ip_identification; /**< [D2.TM.TMM.AT]  Ip identification select enable*/
    uint8  ip_pkt_len;        /**< [D2.TM.TMM.AT]  Ip packet length select enable*/
    uint8  ip_frag;           /**< [D2.TM.TMM.AT]  Ip fragment select enable*/
    uint8  tcp_flags;         /**< [D2.TM.TMM.AT]  Tcp flags select enable, consist of CWR|ECE|URG|ACK|PSH|RST|SYN|FIN */
    uint8  vrfid;             /**< [D2.TM.TMM.AT]  Vrfid select enable, for arctic, ipv4 single key also support*/
    uint8  fid;               /**< [TMM.AT]  Fid which use for l2/vxlan/gre/mpls tunnel l2 forwarding id, arctic ipv4 single key support*/
    uint8  vxlan_vni;         /**< [GG.D2.TM.TMM.AT]  VXLAN select enable*/
    uint8  gre_key;           /**< [GG.D2.TM.TMM.AT]  GRE select enable*/
    uint8  nvgre_key;         /**< [D2.TM.TMM.AT]  NVGRE vsid select enable*/
    uint8  src_cid;           /**< [D2.TM.TMM.AT]  src category id select enable*/
    uint8  dst_cid;           /**< [D2.TM.TMM.AT]  dst category id select enable*/
};
typedef struct ctc_ipfix_hash_ipv4_field_sel_s ctc_ipfix_hash_ipv4_field_sel_t;
/**
 @brief define ipfix hash mpls field sel
*/
struct ctc_ipfix_hash_mpls_field_sel_s
{
    /* Single key */
    uint8 label_num;            /**< [GG.D2.TM.TMM.AT]  MPLS lable number select enable*/
    uint8 mpls_label0_label;    /**< [GG.D2.TM.TMM.AT]  MPLS lable0 select enable*/
    uint8 mpls_label0_exp;      /**< [GG.D2.TM.TMM.AT]  MPLS lable0_exp select enable*/
    uint8 mpls_label0_s;        /**< [GG.D2.TM.TMM.AT]  MPLS lable0_s select enable*/
    uint8 mpls_label0_ttl;      /**< [GG.D2.TM.TMM.AT]  MPLS lable0_ttl select enable*/
    uint8 mpls_label1_label;    /**< [GG.D2.TM.TMM.AT]  MPLS lable1 select enable*/
    uint8 mpls_label1_exp;      /**< [GG.D2.TM.TMM.AT]  MPLS lable1_exp select enable*/
    uint8 mpls_label1_s;        /**< [GG.D2.TM.TMM.AT]  MPLS lable1_s select enable*/
    uint8 mpls_label1_ttl;      /**< [GG.D2.TM.TMM.AT]  MPLS lable1_ttl select enable*/
    uint8 mpls_label2_label;    /**< [GG.D2.TM.TMM.AT]  MPLS lable2 select enable*/
    uint8 mpls_label2_exp;      /**< [GG.D2.TM.TMM.AT]  MPLS lable2_exp select enable*/
    uint8 mpls_label2_s;        /**< [GG.D2.TM.TMM.AT]  MPLS lable2_s select enable*/
    uint8 mpls_label2_ttl;      /**< [GG.D2.TM.TMM.AT]  MPLS lable2_ttl select enable*/

    uint8 profile_id;           /**< [D2.TM.TMM.AT]  config profile id select enable*/

    /* full key */
    uint8 logic_port;           /**< [GG.D2.TM.TMM.AT]  Logic port select enable*/
    uint8 gport;                /**< [GG.D2.TM.TMM.AT]  Gport select enable*/
    uint8 metadata;             /**< [GG.D2.TM.TMM.AT]  Metadata select enable*/
    uint8 fid;                  /**< [TMM.AT]  Fid which use for l2/vxlan/gre/mpls tunnel l2 forwarding id*/
};
typedef struct ctc_ipfix_hash_mpls_field_sel_s ctc_ipfix_hash_mpls_field_sel_t;
/**
 @brief define ipfix hash ipv6 field sel
*/
struct ctc_ipfix_hash_ipv6_field_sel_s
{
    /* Single key */
    uint8 ip_da;                /**< [GG.D2.TM.TMM.AT]  IP DA select enable*/
    uint8 ip_da_mask;           /**< [GG.D2.TM.TMM.AT]  Mask len value4,8,12,...,128 */
    uint8 ip_sa;                /**< [GG.D2.TM.TMM.AT]  IP SA select enable*/
    uint8 ip_sa_mask;           /**< [GG.D2.TM.TMM.AT]  Mask len value4,8,12,...,128 */
    uint8 ip_protocol;          /**< [D2.TM.TMM.AT]  Ip protocol select enable*/
    uint8 l4_src_port;          /**< [GG.D2.TM.TMM.AT]  l4 source port select enable*/
    uint8 l4_dst_port;          /**< [GG.D2.TM.TMM.AT]  l4 destination port select enable*/

    uint8 icmp_type;            /**< [GG.D2.TM.TMM.AT]  ICMP type select enable*/
    uint8 icmp_code;            /**< [GG.D2.TM.TMM.AT]  ICMP code select enable*/
    uint8 igmp_type;            /**< [D2.TM.TMM.AT]  IGMP type select enable*/

    uint8 sym_session_en;       /**< [TMM.AT]  Ip sysmetric session enable which ipda/ipsa and tcp src/dst five tuple as one session*/
    uint8 profile_id;           /**< [D2.TM.TMM.AT]  config profile id select enable*/
    uint8 ipv6_low_en;        /**< [AT] config ipv6 short low 64 bit select enable*/    
    uint8 vrfid;                /**< [AT]  Vrfid select enable*/

    /* full key */
    uint8 gport;                /**< [GG.D2.TM.TMM.AT]  Gport select enable*/
    uint8 logic_port;           /**< [GG.D2.TM.TMM.AT]  Logic port select enable*/
    uint8 metadata;             /**< [GG.D2.TM.TMM.AT]  Metadata select enable*/
    uint8 dscp;                 /**< [GG.D2.TM.TMM.AT]  DSCP select enable*/
    uint8 ttl;                  /**< [D2.TM.TMM.AT]  TTL select enable*/
    uint8 ecn;                  /**< [D2.TM.TMM.AT]  ECN select enable*/
    uint8 flow_label;           /**< [GG.D2.TM.TMM.AT]  flow_label select enable*/
    uint8 l4_type;              /**< [GG] l4_type select enable*/
    uint8 l4_sub_type;          /**< [GG] Before cfg l4_sub_type, first enable l4_type. Only support VXLAN*/
    uint8 fid;                  /**< [TMM.AT]  Fid which use for l2/vxlan/gre/mpls tunnel l2 forwarding id. For AT, single key support fid*/
    uint8 vxlan_vni;            /**< [GG.D2.TM.TMM.AT]  VXLAN select enable*/
    uint8 gre_key;              /**< [GG.D2.TM.TMM.AT]  GRE select enable*/
    uint8 nvgre_key;            /**< [D2.TM.TMM.AT]  NVGRE vsid select enable*/
    uint8 aware_tunnel_info_en; /**< [D2.TM.TMM.AT]  if enable, indicate lookup key use innner info as key, and outer tunnel info can also be used as lookup key*/
    uint8 wlan_radio_mac;       /**< [D2.TM] Wlan radio mac enable*/
    uint8 wlan_radio_id;        /**< [D2.TM] Wlan radio id enable*/
    uint8 wlan_ctl_packet;      /**< [D2.TM] Wlan control packet enable */
    uint8 ip_frag;              /**< [D2.TM.TMM.AT]  Ip fragment select enable*/
    uint8 tcp_flags;            /**< [D2.TM.TMM.AT]  Tcp flags select enable, consist of CWR|ECE|URG|ACK|PSH|RST|SYN|FIN*/
    uint8 src_cid;              /**< [D2.TM.TMM.AT]  src category id select enable*/
    uint8 dst_cid;              /**< [D2.TM.TMM.AT]  dst category id select enable*/
};
typedef struct ctc_ipfix_hash_ipv6_field_sel_s ctc_ipfix_hash_ipv6_field_sel_t;
/**
 @brief define ipfix hash l2l3 field sel
*/
struct ctc_ipfix_hash_l2_l3_field_sel_s
{
    uint8 gport;                /**< [GG.D2.TM.TMM.AT]  Gport select enable*/
    uint8 logic_port;           /**< [GG.D2.TM.TMM.AT]  Logic port select enable*/
    uint8 metadata;             /**< [GG.D2.TM.TMM.AT]  Metadata select enable*/
    uint8 mac_da;               /**< [GG.D2.TM.TMM.AT]  MAC DA select enable*/
    uint8 mac_sa;               /**< [GG.D2.TM.TMM.AT]  MAC SA select enable*/
    uint8 stag_cos;             /**< [GG.D2.TM.TMM.AT]  SVLAN COS select enable*/
    uint8 stag_cfi;             /**< [GG.D2.TM.TMM.AT]  SVLAN CFI select enable*/
    uint8 stag_vlan;            /**< [GG.D2.TM.TMM.AT]  SVLAN select enable*/
    uint8 ctag_cos;             /**< [GG.D2.TM.TMM.AT]  CVLAN COS select enable*/
    uint8 ctag_cfi;             /**< [GG.D2.TM.TMM.AT]  CVLAN CFI select enable*/
    uint8 ctag_vlan;            /**< [GG.D2.TM.TMM.AT]  CVLAN select enable*/

    uint8 ip_da;                /**< [GG.D2.TM.TMM.AT]  IP DA select enable*/
    uint8 ip_da_mask;           /**< [GG.D2.TM.TMM.AT]  IP DA mask length*/
    uint8 ip_sa;                /**< [GG.D2.TM.TMM.AT]  IP SA select enable*/
    uint8 ip_sa_mask;           /**< [GG.D2.TM.TMM.AT]  IP SA mask length*/
    uint8 dscp;                 /**< [GG.D2.TM.TMM.AT]  DSCP select enable*/
    uint8 ecn;                  /**< [GG.D2.TM.TMM.AT]  ECN select enable*/
    uint8 ttl;                  /**< [GG.D2.TM.TMM.AT]  TTL select enable*/
    uint8 eth_type;             /**< [GG.D2.TM.TMM.AT]  Eth_type select enable*/
    uint8 vrfid;                /**< [GG.D2.TM.TMM.AT]  vrfid select enable*/
    uint8 l4_type;              /**< [GG] L4 type select enable*/
    uint8 l4_sub_type;          /**< [GG] Before cfg l4_sub_type, first enable l4_type*/
    uint8 ip_protocol;          /**< [D2.TM.TMM.AT]  IP protocol select enable*/
    uint8 ip_identification;    /**< [D2.TM.TMM.AT]  Ip identification select enable*/
    uint8 ip_frag;              /**< [D2.TM.TMM.AT]  Ip fragment select enable*/
    uint8 tcp_flags;            /**< [D2.TM.TMM.AT]  Tcp flags select enable, consist of CWR|ECE|URG|ACK|PSH|RST|SYN|FIN*/
    uint8  sym_session_en;      /**< [TMM.AT]  Ip sysmetric session enable which ipda/ipsa and tcp src/dst five tuple as one session*/
    uint8  fid;                 /**< [TMM.AT]  Fid which use for l2/vxlan/gre/mpls tunnel l2 forwarding id*/

    uint8 gre_key;              /**< [GG.D2.TM.TMM.AT]  GRE select enable*/
    uint8 nvgre_key;            /**< [D2.TM.TMM.AT]  NVGRE vsid select enable*/
    uint8 vxlan_vni;            /**< [GG.D2.TM.TMM.AT]  Vxlan select enable*/
    uint8 aware_tunnel_info_en; /**< [D2.TM.TMM.AT]  if enable, indicate lookup key use innner info as key, and outer tunnel info can also be used as lookup key*/
    uint8 wlan_radio_mac;       /**< [D2.TM] Wlan radio mac enable*/
    uint8 wlan_radio_id;        /**< [D2.TM] Wlan radio id enable*/
    uint8 wlan_ctl_packet;      /**< [D2.TM] Wlan control packet enable */
    uint8 l4_src_port;          /**< [GG.D2.TM.TMM.AT]  l4 source port select enable*/
    uint8 l4_dst_port;          /**< [GG.D2.TM.TMM.AT]  l4 destination port select enable*/
    uint8 icmp_type;            /**< [GG.D2.TM.TMM.AT]  ICMP type select enable*/
    uint8 icmp_code;            /**< [GG.D2.TM.TMM.AT]  ICMP code select enable*/
    uint8 igmp_type;            /**< [D2.TM.TMM.AT]  IGMP type select enable*/

    uint8 label_num;            /**< [GG.D2.TM.TMM.AT]  MPLS lable number select enable*/
    uint8 mpls_label0_label;    /**< [GG.D2.TM.TMM.AT]  MPLS lable0 select enable*/
    uint8 mpls_label0_exp;      /**< [GG.D2.TM.TMM.AT]  MPLS lable0_exp select enable*/
    uint8 mpls_label0_s;        /**< [GG.D2.TM.TMM.AT]  MPLS lable0_s select enable*/
    uint8 mpls_label0_ttl;      /**< [GG.D2.TM.TMM.AT]  MPLS lable0_ttl select enable*/
    uint8 mpls_label1_label;    /**< [GG.D2.TM.TMM.AT]  MPLS lable1 select enable*/
    uint8 mpls_label1_exp;      /**< [GG.D2.TM.TMM.AT]  MPLS lable1_exp select enable*/
    uint8 mpls_label1_s;        /**< [GG.D2.TM.TMM.AT]  MPLS lable1_s select enable*/
    uint8 mpls_label1_ttl;      /**< [GG.D2.TM.TMM.AT]  MPLS lable1_ttl select enable*/
    uint8 mpls_label2_label;    /**< [GG.D2.TM.TMM.AT]  MPLS lable2 select enable*/
    uint8 mpls_label2_exp;      /**< [GG.D2.TM.TMM.AT]  MPLS lable2_exp select enable*/
    uint8 mpls_label2_s;        /**< [GG.D2.TM.TMM.AT]  MPLS lable2_s select enable*/
    uint8 mpls_label2_ttl;      /**< [GG.D2.TM.TMM.AT]  MPLS lable2_ttl select enable*/
    uint8 src_cid;              /**< [D2.TM.TMM.AT]  src category id select enable*/
    uint8 dst_cid;              /**< [D2.TM.TMM.AT]  dst category id select enable*/
    uint8 profile_id;           /**< [D2.TM.TMM.AT]  config profile id select enable*/
    uint8 arp_code;             /**< [AT] config arp code enable*/
    uint8 arp_mac_sa;           /**< [AT] ARP MAC SA select enable*/
    uint8 arp_mac_da;           /**< [AT] ARP MAC DA select enable*/
};
typedef struct ctc_ipfix_hash_l2_l3_field_sel_s ctc_ipfix_hash_l2_l3_field_sel_t;
/**
 @brief define ipfix hash udf field sel
*/
struct ctc_ipfix_hash_udf_field_sel_s
{
  /* single key */
    uint8   udf_data[CTC_ACL_UDF_BYTE_NUM];      /**< [AT] Select udf data bitmap(128bits)*/
    uint16  udf_valid;                           /**< [AT] Select udf valid bitmap(8bits), per bucks for udf data*/
    uint8  profile_id;                           /**< [AT] config profile id select enable*/

    /* full key */
    uint8 logic_port;                            /**< [AT] Logic port select enable*/
    uint8 gport;                                 /**< [AT] Gport select enable*/
    uint8 metadata;                              /**< [AT] Metadata select enable*/
};
typedef struct ctc_ipfix_hash_udf_field_sel_s ctc_ipfix_hash_udf_field_sel_t;
/**
 @brief define ipfix hash field sel
*/
struct ctc_ipfix_hash_field_sel_s
{
    uint8  key_type;                            /**< [GG.D2.TM.TMM.AT]  Refer ctc_ipfix_key_type_t */
    uint8  field_sel_id;                        /**< [GG.D2.TM.TMM.AT]  Hash select ID */
    union
    {
        ctc_ipfix_hash_mac_field_sel_t   mac;   /**< [GG.D2.TM.TMM.AT]  Hash key type is mac key*/
        ctc_ipfix_hash_mpls_field_sel_t  mpls;  /**< [GG.D2.TM.TMM.AT]  Hash key type is mpls key*/
        ctc_ipfix_hash_ipv4_field_sel_t  ipv4;  /**< [GG.D2.TM.TMM.AT]  Hash key type is ipv4 key*/
        ctc_ipfix_hash_ipv6_field_sel_t  ipv6;  /**< [GG.D2.TM.TMM.AT]  Hash key type is ipv6 key*/
        ctc_ipfix_hash_l2_l3_field_sel_t l2_l3; /**< [GG.D2.TM.TMM.AT]  Hash key type is l2l3 key*/
        ctc_ipfix_hash_udf_field_sel_t  udf;    /**< [AT] Hash key type is UDF*/
    }u;
};
typedef struct ctc_ipfix_hash_field_sel_s ctc_ipfix_hash_field_sel_t;

/**
 @brief define ipfix port configuration
*/
struct ctc_ipfix_port_cfg_s
{
    uint8   dir;                    /**< [GG] Direction*/
    uint8   lkup_type;              /**< [GG] Refer to ctc_ipfix_lkup_type_t */
    uint8   field_sel_id;           /**< [GG] Field select id , used associate with ctc_ipfix_key_type_t */
    uint8   tcp_end_detect_disable; /**< [GG] Tcp end detect disable*/
    uint8   flow_type;              /**< [GG] Packet type, refer to ctc_ipfix_flow_type_t*/
    uint8   learn_disable;          /**< [GG] Disable learn new flow based port*/
    uint16  sample_interval;        /**< [GG] Global support for packet interval*/
};
typedef struct ctc_ipfix_port_cfg_s ctc_ipfix_port_cfg_t;
/**
 @brief define ipfix track type
*/
enum ctc_ipfix_flow_track_type_e
{
   CTC_IPFIX_FLOW_TRACK_BURST_EVENT,        /**< [AT] The burst overflow event  */
   CTC_IPFIX_FLOW_TRACK_LATENCY_EVENT,      /**< [AT] The latency overflow event  */
   CTC_IPFIX_FLOW_TRACK_MAX_LATENCY,        /**< [AT] The max latency  */
   CTC_IPFIX_FLOW_TRACK_MIN_LATENCY,        /**< [AT] The minium latency  */
   CTC_IPFIX_FLOW_TRACK_AVG_LATENCY,        /**< [AT] The average latency */
   CTC_IPFIX_FLOW_TRACK_TS,                 /**< [AT] The timestamp value */

   CTC_IPFIX_FLOW_TRACK_MAX
};
typedef enum ctc_ipfix_flow_track_type_e ctc_ipfix_flow_track_type_t;
/**
 @brief define ipfix flow track
*/
struct ctc_ipfix_flow_track_s
{
    uint8 type;                 /**< [AT] Flow track type, refer to ctc_ipfix_flow_track_type_t*/
    uint8 valid;                /**< [AT] Whether flow track type valid, if set 0, disable, if set 1, enable*/
    uint8 count_mode;           /**< [AT] 0: 16bits width,1: 32bits width*/
    uint32 count_thrd;          /**< [AT] Flow track count threshold*/
};
typedef struct ctc_ipfix_flow_track_s ctc_ipfix_flow_track_t;

/**
 @brief define ipfix flow cfg
*/
struct ctc_ipfix_flow_cfg_s
{
    uint8   profile_id;             /**< [D2.TM.TMM.AT]  Config profile id.*/
    uint8   dir;                    /**< [D2.TM.TMM.AT]  Direction*/
    uint8   tcp_end_detect_disable; /**< [D2.TM.TMM.AT]  Tcp end detect disable based on flow. */
    uint8   log_pkt_count;          /**< [D2.TM.TMM.AT]  Log/mirror the first N packets for new flow. */
    uint16  flow_type;              /**< [D2.TM.TMM.AT]  Packet type, refer to ctc_ipfix_flow_type_t*/	
    uint8   learn_disable;          /**< [D2.TM.TMM.AT]  Disable learn new flow based on flow. */
    uint8   sample_mode;            /**< [D2.TM.TMM.AT]  Sample mode,0:fixed interval 1:random mode*/
    uint8   sample_type;            /**< [D2.TM.TMM.AT]  Sample type,0:based on all packets, 1: based on unkown packet*/
    uint16  sample_interval;        /**< [D2.TM.TMM.AT]  if sample_interval = N, then do ipfix probability 1/N. */

    uint8   drop_pkt_mode;          /**< [TMM.AT]  When ignore_drop_reason of global cfg is disable,
                                               0: count the bitmap of dropped reason;
                                               1: count the number of first two dropped reasons configured by drop_report_bmp*/
    uint32  drop_report_bmp[2];     /**< [TMM.AT]  Drop reason report enable bitmap, refer to ctc_drop_reason_t*/
    uint32  suppress_reason_bmp;    /**< [TMM.AT]  Suppress export reason recorded, refer to ctc_ipfix_export_reason_t */
    uint32  deny_export_reason_bmp; /**< [TMM.AT]  Deny export reason to DMA, refer to ctc_ipfix_export_reason_t*/
    ctc_ipfix_flow_track_t track[CTC_IPFIX_FLOW_TRACK_MAX];   /**< [AT] Storage flow track parameter */

    uint16 pp_bmp;                 /**< [AT] PP bitmap */
};
typedef struct ctc_ipfix_flow_cfg_s ctc_ipfix_flow_cfg_t;


/**
 @brief define ipfix global config information
*/
struct ctc_ipfix_global_cfg_s
{
    uint32  aging_interval;        /**< [GG.D2.TM.TMM.AT]  Aging interval (s) (default: 0) */
    uint32  pkt_cnt;               /**< [GG.D2.TM.TMM.AT]  Number of packets to be export. (default: 100)*/
    uint64  bytes_cnt;             /**< [GG.D2.TM.TMM.AT]  Number of bytes threshold to be export. (default: 9600)*/
    uint32  times_interval;        /**< [GG.D2.TM.TMM.AT]  Number of times interval to be export. (default: 1000)*/
    uint8   sample_mode;           /**< [GG] Sample mode, 0: based on all packet, 1: based on unknown packet (default: 0)*/
    uint8   conflict_export;       /**< [GG.D2.TM.TMM.AT]  Conflict entry export to cpu (default: 0)*/
    uint8   tcp_end_detect_en;     /**< [GG.D2.TM.TMM.AT]  Global enable tcp end detect (default: 1)*/
    uint8   new_flow_export_en;    /**< [GG.D2.TM.TMM.AT]  New flow export control (default: 0)*/
    uint8   sw_learning_en;        /**< [GG.D2.TM.TMM.AT]  Cpu add key and delete key, asic only do update, not insert (default: 0)*/
    uint8   unkown_pkt_dest_type;  /**< [GG.D2.TM.TMM.AT]  0:using group id, 1:using vlan id (default: 0)*/
    uint32  threshold;             /**< [D2.TM.TMM.AT]  if flow count up/down to threshold will trigger interrupt (default: 0)*/

    uint8   latency_type;          /**< [TM] Monitor latency type, 0: monitor latency stats, 1:monitor jitter stats (default: 0)*/
    uint32  conflict_cnt;          /**< [D2.TM.TMM.AT]  Conflict entry counter (default: 0)*/

    uint32  export_interval;       /**< [TMM.AT]  Export reason interval (ms) (default: 100)*/
    uint16  drop_pkt_cnt;          /**< [TMM.AT]  Number of packets drop threshold to be export. (default: 512)*/

    uint32  jitter_thrd;           /**< [TMM.AT]  Jitter threshold to be export (default: 0)*/
    uint32  latency_thrd;          /**< [TMM.AT]  Latency threshold to be export (default: 0)*/
    uint8   jitter_ewma_weight;    /**< [TMM.AT]  Jitter average ewma weight (default: 0)*/
    uint8   latency_ewma_weight;   /**< [TMM.AT]  Latency average ewma weight (default: 0)*/
    uint8   queue_drop_en;         /**< [TMM.AT]  Use spanondrop to realize Ipfix per-flow queue drop stats, if set 1, spanondrop discard (default: 0)*/
    uint8   ignore_drop_reason;    /**< [TMM.AT]  If set, statistics on dropped packet will ignore dropped reason (default: 0)*/
    uint8   egs_ipfix_disable;     /**< [TMM]  Disable egress ipfix if set (default: 0)*/
    uint8   dest_port_type;        /**< [D2.TM.TMM.AT]  If set, when dest port is linkagg, dest port in export data will use member port (default: 0)*/
    uint8   mirror_pkt_enable;     /**< [D2.TM.TMM.AT]  If set, mirrored packet will do ipfix as normal packet (default: 0)*/
    uint16  max_export_entry_num;  /**< [TMM.AT]  The max export entry num to user for call back (default: 1024)*/
    uint16 pp_bmp;                /**< [AT] PP bitmap */
};
typedef struct ctc_ipfix_global_cfg_s ctc_ipfix_global_cfg_t;
/**
 @brief define ipfix traverse type
*/
enum ctc_ipfix_traverse_type_e
{
    CTC_IPFIX_TRAVERSE_BY_ALL,     /**< [GG.D2.TM.TMM.AT]  Traverse by all */
    CTC_IPFIX_TRAVERSE_BY_PORT,    /**< [GG.D2.TM.TMM.AT]  Traverse by port */
    CTC_IPFIX_TRAVERSE_BY_DIR,     /**< [GG.D2.TM.TMM.AT]  Traverse by direction */
    CTC_IPFIX_TRAVERSE_BY_PORT_DIR /**< [GG.D2.TM.TMM.AT]  Traverse by port and direction */
};
typedef enum ctc_ipfix_traverse_type_e ctc_ipfix_traverse_type_t;

/**
 @brief define ipfix traverse
*/
struct ctc_ipfix_traverse_s
{
    void*   user_data;           /**< [GG.D2.TM.TMM.AT]  User data*/
    uint32  start_index;         /**< [GG.D2.TM.TMM.AT]  If it is the first traverse, it is equal to 0, else it is equal to the last next_traverse_index */
    uint32  next_traverse_index; /**< [GG.D2.TM.TMM.AT]  [out] return index of the next traverse */
    uint8   is_end;              /**< [GG.D2.TM.TMM.AT]  [out] if is_end == 1, indicate the end of traverse */
    uint16  entry_num;           /**< [GG.D2.TM.TMM.AT]  indicate entry number for one traverse function. 
                                  For TMM hardware dump, it means the scan range [start_index,start_index+entry_num], the user should get the "one_round_done" 
                                  in struct ctc_ipfix_bulk_op_miss_t to make sure the dump is completed, and get "miss_cnt" which means it exists dump failed entry
                                  when it is not equal zero, in this case, users should dump again with smaller entry_num to make sure the data's completeness.
                                  For AT hardware dump,it means that we should dump the number of existing entry,it is different from TMM.
                                  */
    uint8   lchip_id;            /**< [D2.TM.TMM.AT]     Traverse entry for specific local device id */
    uint8   dir;                 /**< [AT] Dump dir, refer to ctc_direction_t */
    uint8   pp_id;               /**< [AT] PP id */
};
typedef struct ctc_ipfix_traverse_s ctc_ipfix_traverse_t;

typedef void (*ctc_ipfix_fn_t)( ctc_ipfix_data_t* info, void* userdata);           /* ctc_ipfix_fn_t */
typedef int32 (* ctc_ipfix_traverse_fn)(ctc_ipfix_data_t* p_data, void* user_data);
typedef ctc_ipfix_traverse_fn ctc_ipfix_traverse_remove_cmp;
struct ctc_ipfix_event_s
{
    uint8 exceed_threshold;       /**< [D2.TM.TMM.AT]  if set, measns flow count exceed threshold else down to threshold */
    uint8 pp_id;                  /**< [AT] Interrupt event export pp id */
    uint8 dir;                    /**< [AT] Interrupt event dir, refer to ctc_direction_t */
    uint8 rsv;
};
typedef struct ctc_ipfix_event_s ctc_ipfix_event_t;

/**
 @brief  Define ipfix property update structure
*/
struct ctc_ipfix_property_s
{
    uint32 type;                 /**< [TMM.AT]  property type, refer to ctc_ipfix_property_type_t */
    void * value;                /**< [TMM.AT]  property value, according to property type */
    uint16 pp_bmp;              /**< [AT] PP bitmap */
};
typedef struct ctc_ipfix_property_s ctc_ipfix_property_t;

/**
 @brief define ipfix operation flag
*/
enum ctc_ipfix_op_flag_e
{
   CTC_IPFIX_OP_FLAG_BY_PROF      = 1U << 0,      /**< [TMM.AT]  if set 1, indicate operation by profile id, otherwise operation all entry. */
   CTC_IPFIX_OP_FLAG_DUMP_EN      = 1U << 1,      /**< [TMM.AT]  enable dump entry */
   CTC_IPFIX_OP_FLAG_FLUSH_EN     = 1U << 2,      /**< [TMM.AT]  enable flush entry */

   CTC_IPFIX_OP_FLAG_MAX
};
typedef enum ctc_ipfix_op_flag_e ctc_ipfix_op_flag_t;

typedef struct ctc_ipfix_traverse_s ctc_ipfix_bulk_param_t;
/**
 @brief define ipfix bulk op
*/
struct ctc_ipfix_bulk_op_s
{
    uint32 flag;                                  /**< [TMM.AT]  operation flag refer to ctc_ipfix_op_flag_t*/
    uint8  prof_id;                               /**< [TMM.AT]  profile id*/
    ctc_ipfix_bulk_param_t * p_param;             /**< [TMM.AT]  dump/flush in specific section*/
    uint32 prof_id_bmp[CTC_IPFIX_PROFILE_NUM/32]; /*<[AT] dump/flush profile bmp*/
} ;
typedef struct ctc_ipfix_bulk_op_s ctc_ipfix_bulk_op_t;

/**
 @brief define ipfix bulk op miss
*/
struct ctc_ipfix_bulk_op_miss_s
{
    uint32 miss_cnt;              /**< [TMM.AT]  out, indicate miss count due to dma is full when dump */
    uint8  one_round_done;        /**< [TMM.AT]  out, if 1, indicate dump/flush one round complete */
    uint8  dir;                   /**< [AT] direction */
} ;
typedef struct ctc_ipfix_bulk_op_miss_s ctc_ipfix_bulk_op_miss_t;

/**
 @brief define ipfix mburst threshold
*/
struct ctc_ipfix_mburst_thrd_s
{
    uint32  mburst_on_thrd;        /**< [AT] Max queue count export threshold(default: 0x3FFFF) */
    uint32  mburst_off_thrd;       /**< [AT] Min queue count export threshold(default: 0xFFFF) */
    uint8   mburst_cnt_thrd;       /**< [AT] the times' threshold of the queue buffer count exceeding the congestion threshold continuously*/
} ;
typedef struct ctc_ipfix_mburst_thrd_s ctc_ipfix_mburst_thrd_t;

/**
 @brief define ipfix update type
*/
enum ctc_ipfix_property_type_e
{
    CTC_IPFIX_PROP_NONE,                  /**< [TMM.AT]  none */
    CTC_IPFIX_PROP_BULK_OP,               /**< [TMM.AT]  bulk operation, refer to ctc_ipfix_bulk_op_t */
    CTC_IPFIX_PROP_BULK_MISS,             /**< [TMM.AT]  out, bulk operation miss status, refer to ctc_ipfix_bulk_op_miss_t */    
    CTC_IPFIX_PROP_MBURST,                /**< [TMM.AT] MMU burst count status, refer to ctc_ipfix_mburst_thrd_t */
    CTC_IPFIX_PROP_HASH_CONFLICT_THRD,    /**< [AT] if 0,Ipfix hash conflict export disable,the vlaue is 0~8k */
    CTC_IPFIX_PROP_LOW_LATENCY,           /**< [AT] if 1,Ipfix not surport mirror, discard, buffer drop functions */

    CTC_IPFIX_PROP_MAX
};
typedef enum ctc_ipfix_property_type_e ctc_ipfix_property_type_t;

/**
 @brief define ipfix flex key
*/
typedef struct ctc_ipfix_flex_kset_s {
    uint32 w[CTC_B2W_SIZE(CTC_FIELD_KEY_NUM)];/**< [AT] Flex kset words*/
}ctc_ipfix_kset_t;

struct ctc_ipfix_flex_key_s
{
    uint8  key_type;                     /**< [AT] new key type ,refer to ctc_ipfix_key_type_t*/
    uint8  origin_key_type;              /**< [AT] origin key type, refer to ctc_ipfix_key_type_t*/
    uint8  dir;                          /**< [AT] direction, refer to ctc_direction_t */
    uint8  mode;                         /**< [AT] key mode, refer to ctc_field_flex_key_mode_t */
    uint32 flex_bits;                    /**< [AT] [out] flex key bits*/
    ctc_ipfix_kset_t kset;               /**< [AT] ipfix flex key fields */
    ctc_xdata_t* xdata;                  /**< [AT] local xdata, only valid for CTC_FIELD_KEY_XDATA */
};
typedef struct ctc_ipfix_flex_key_s ctc_ipfix_flex_key_t; 

/**@} end of @defgroup ipfix  */

#ifdef __cplusplus
}
#endif

#endif
